<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class Menu {

    private $mMenu = array();
    

    private function GetMenuIndexOf($pKat, $pTitle = null) {
        $pTitle= strtoupper($pTitle);
        switch ($pKat) {
            case 'master': {
                    $tCount = count($this->mMenu["MASTER DATA"]);
                    break;
                }
            case 'inisialisasi': {
                    $tCount = count($this->mMenu["INISIALISASI"]);
                    break;
                }
            case 'verifikasi': {
                    $tCount = count($this->mMenu["VERIFIKASI"]);
                    break;
                }
            case 'persetujuan': {
                    $tCount = count($this->mMenu["PERSETUJUAN"]);
                    break;
                }
            case 'menu': {
                    $tCount = count($this->mMenu[$pTitle]);
                    break;
                }
            case 'sub': {
                    $tCount = count($this->mMenu[$pTitle]);
                    break;
                }
        }
        (!empty($tCount)) ? $tIndex = $tCount : $tIndex = 0;

        return $tIndex;
    }

    public function AddMenuMaster($pCaption, $pLink) {
        $tIndex = $this->GetMenuIndexOf("master");

        $this->mMenu["MASTER DATA"][$tIndex][Caption] = $pCaption;
        $this->mMenu["MASTER DATA"][$tIndex][Link] = $pLink;
    }

    public function AddMenuInisialisasi($pCaption, $pLink) {
        $tIndex = $this->GetMenuIndexOf("inisialisasi");

        $this->mMenu["INISIALISASI"][$tIndex][Caption] = $pCaption;
        $this->mMenu["INISIALISASI"][$tIndex][Link] = $pLink;
    }
    
    public function AddMenuVerifikasi($pCaption, $pLink) {
        $tIndex = $this->GetMenuIndexOf("verifikasi");

        $this->mMenu["VERIFIKASI"][$tIndex][Caption] = $pCaption;
        $this->mMenu["VERIFIKASI"][$tIndex][Link] = $pLink;
    }
    
    public function AddMenuPersetujuan($pCaption, $pLink) {
        $tIndex = $this->GetMenuIndexOf("persetujuan");

        $this->mMenu["PERSETUJUAN"][$tIndex][Caption] = $pCaption;
        $this->mMenu["PERSETUJUAN"][$tIndex][Link] = $pLink;
    }

    public function AddMenu($pCaption, $pLink) {
        $tIndex = $this->GetMenuIndexOf("menu", $pCaption);

        $this->mMenu[strtoupper($pCaption)][$tIndex][Caption] = $pCaption;
        $this->mMenu[strtoupper($pCaption)][$tIndex][Link] = $pLink;
    }

    public function AddMenuSub($pTitle, $pCaption, $pLink) {
        $pTitle= strtoupper($pTitle);
        $tIndex = $this->GetMenuIndexOf("sub", $pTitle);
        $this->mMenu[$pTitle][$tIndex][Caption] = $pCaption;
        $this->mMenu[$pTitle][$tIndex][Link] = $pLink;
    }
    
    public function GetMenu(){
        /*$tMenu= $this->mMenu["MASTER DATA"];
        $tResult= array();
        
        $i=0;
        while($tMenu[$i]){
            $tResult[0][$i][Title]="Master";
            $tResult[0][$i][Caption]=$this->mMenuMaster[$i][Caption];
            $tResult[0][$i][Link]=$this->mMenuMaster[$i][Link];
            $i++;
        }*/
        
        return $this->mMenu;
    }

}

?>
